// import JSEncrypt from 'jsencrypt'

// rsa加密
// const rsaEncode = (info) => {
//     var encrypt = new JSEncrypt();
//     encrypt.setKey('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDgISYI7fJI7kY4IcMvS1m3KQNXvFiMgKOLfx9fOamQwnI9tCKUaQ26a+NJ/LB3W1pVIrtfFFIbVwuqDKgFD465W4qWWd9UeCHP1awYZlr8SoO6PSfXNJuZQ+HAOaksVbrQDtSJP+o+P5POFT+Xu3S/CaU89p/wbYmiE3CkNoynDwIDAQAB');
//     let data = encrypt.encryptUnicodeLong(info);
//     return data
// }

// const rsaUnEncode = (info) => {
//     var decrypt = new JSEncrypt();
//     decrypt.setKey('MIICXQIBAAKBgQDgISYI7fJI7kY4IcMvS1m3KQNXvFiMgKOLfx9fOamQwnI9tCKUaQ26a+NJ/LB3W1pVIrtfFFIbVwuqDKgFD465W4qWWd9UeCHP1awYZlr8SoO6PSfXNJuZQ+HAOaksVbrQDtSJP+o+P5POFT+Xu3S/CaU89p/wbYmiE3CkNoynDwIDAQABAoGBAK6BwM6FDfcw5qV/zCw/u+u7WCnwsPU8l5necbu/9sGKVE6suZvaK+ExbXfG8lMMYsoUz9TYypEU9jUBw7SlB1bfwR5Cf1G7vKF0usLPhsPb+feSC0W9eWMD2HVu22PZu2axYL7cD659INCqQpIwzVX/ogdbhajb8p3EISqYtQuRAkEA9nwRfyCQzc+fDw+SDwK1MJ2cNvtIpeaU1K10iNhbKPy3W9Wb1XGuRP7Sxf3g4/ST1LA3q0KZdPu2WkZ6bGnDSQJBAOjIJrAu96Anppy4AotfbMowwHFfPoStdZcv39RkS//KFwJ1BS6i1R5PqJHUmSjeMo6OAfXbCFPACVwV5Wi/v5cCQEwWurP60pimGhzlGpqFpHdQgDO82I1WI+WPciT4XRPHB7dStptqT3i/DUPPfogALU5/4397vLGPLpipnwsujvkCQEeSMoL9DdnKFyocUXv0rQhFkQXKmPhGNN91Msakx9Evm39/50X9frVBHL0ptqWgG79E3klvPNIzOy169fwM6KUCQQDxdcfw48OlLWQhME7AnJ2NBr+0WTpNgsDWXqG7LMc/ijxbaOwoUuBtVKW46TljxhS1U1rxaXXslFnqOvfR404c');
//     let data = decrypt.decryptUnicodeLong(info);
//     return data
// }

// CryptoJS aes加密
const CryptoJS = require('crypto-js');

const key = CryptoJS.enc.Utf8.parse("1234567834ABCDEF");  //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('ABCDEF1234123412');   //十六位十六进制数作为密钥偏移量

// AES 加密
const AesEncrypt = (v) => {
    let srcs = CryptoJS.enc.Utf8.parse(v);
    let encrypted = CryptoJS.AES.encrypt(srcs, key, { 
        iv: iv, 
        mode: CryptoJS.mode.CBC, 
        padding: CryptoJS.pad.Pkcs7 
    });
    return encrypted.ciphertext.toString().toUpperCase();
}


// AES 解密
const AesDecode = (v) => {
        let encryptedHexStr = CryptoJS.enc.Hex.parse(v);
        let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
        let decrypt = CryptoJS.AES.decrypt(srcs, key, { 
            iv: iv, 
            mode: CryptoJS.mode.CBC, 
            padding: CryptoJS.pad.Pkcs7 
        });
        let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
        return decryptedStr.toString();
}

export { AesEncrypt,AesDecode};